import request from '@/utils/request'

// 获取产品列表
export async function getPageProductCard(params) {
    return await request.get('loanProduct/queryHomePage', {params})
}
// 获取产品列表
export async function getHomePageProduct(params) {
        return await request.get('loanProduct/queryHomePageByOrder', {params})
}
// 获取首页用户状态
export async function getHomeUserStatus(params) {
    return await request.get('homepage/user/status', {params})
}
// 获取首页额度计算
export async function getHomepageLimit(params) {
    return await request.get('homepage/Limit/calculate', {params})
}
// 立即申请
export async function applyLoanProduct(params) {
    return await request.get('immediatelyLoanV3', {params})
}

// 获取公告列表
export async function getNotice() {
    return await request.post('systemNoticeList', {productName: localStorage.getItem('productName')})
}

// 校验用户添加信息
export async function userInfoVerify() {
    return await request.get('user/userInfoVerify')
}

// 上传身份证照片
export async function uploadUserInfo(params) {
    return await request.post('user/dataUpload', params)
}

// 上传人脸照片
export async function uploadFaceUpload(params) {
    return await request.post('user/faceUpload', params)
}

// 上传身份信息
export async function userInfoConfirm(params) {
    return await request.post('user/realUserInfoUpload', params)
}

// 获取个人信息下拉
    export async function personalInfoSelect(params) {
    return await request.post('selectPullDownEnum', params)
}

// 获取省市区联动下拉
export async function selectCitys(params) {
    return await request.get('selectByPid', {params})
}

// 保存用户信息
export async function savePersonalInfo(params) {
    return await request.post('personalInfo', params)
}

// 保存工作信息
export async function saveWorkInfo(params) {
    return await request.post('workInfo', params)
}

// 保存联系人信息
export async function saveContacts(params) {
    return await request.post('saveContacts', params)
}

// 上传工作资料认证
export async function uploadWorkData(params) {
    return await request.post('uploadProof', params)
}

// 获取运营商列表
export async function operatorSelect(params) {
    return await request.get('operator/operatorV2', {params})
}

// 校验运营商认证是否成功
export async function isOperatorAuthSuccess(params) {
    return await request.get('operator/certification', {params})
}

// 跳过运营商认证
export async function jumpOperatorAuth() {
    return await request.post('jumpOverCertification')
}

// 第一次发送验证码
export async function operatorSend_Code1(params) {
    return await request.post('operator/getOtp1', params)
}

// 第二次发送验证码
export async function operatorSend_Code2(params) {
    return await request.post('operator/getOtp2', params)
}

// 提交第二次验证码
export async function submit_code2(params) {
    return await request.post('operator/postOtp', params)
}

// 获取银行卡列表
export async function fetchBankCard(params) {
    return await request.get('selectBlankList', {params})
}

// 添加银行卡列表
export async function addBankCard(params) {
    return await request.post('tiedCard', params)
}

export async function addBankCardMultiple(params) {
    return await request.post('tiedMultipleCard', params)
}
// 获取我的银行卡
export async function fetchMyCard(params) {
    return await request.get('queryCard', {params})
}

// 更新银行卡状态
export async function upDateMyCard(params) {
    return await request.post('updateBankcard', params)
}

// 贷款确认
export async function loanConfirm(params) {
    return await request.get('loanProduct/loanTrial', {params})
}

// 完成申请确认
export async function applyConfirm(params) {
    return await request.post('immediatelyLoanV4', params)
}
// 获取产品贷款详情
export async function fetchLoanProductDetails(params) {
    return await request.get('loanProduct/getCanBorrowProductDetail', {params})
}
// 校验风控需要的app列表和短信是否存在
export async function checkRiskData(params) {
    return await request.get('user/check/riskdata', {params})
}
// 我的贷款详情
export async function myLoanInfo(params) {
    return await request.get('loanRecordDetails', {params})
}

// 获取菜单子级内容展示
export async function fetchMenuChildShow(params) {
    return await request.get('queryResources', {params})
}

// 获取菜单父级内容
export async function fetchMenuFatherShow(params) {
    return await request.get('queryParentLevel', {params})
}

/**
 * 前端埋点
 * type 1pv 2uv
 * @param params
 */
export async function buryingPoint(params) {
    return await request.post('user/appCollectUploadH5', params)
}

/**
 * 添加ad埋点
 * type (1、发送短信（不需要登录）2、登录成功 3、注册成功 4、申请成功)
 * @param params
 */
export async function addAdEvent(params) {
    return await request.post('loan/supermarket/addAdEvent', {
        ...params,
        productName: localStorage.getItem('productName')
    })
}

/**
 * 上传事件Id
 * @param params
 */
export async function uploadAdEvent(params) {
    return await request.post('user/uploadEventId', params)
}

/**
 * 获取验证码Api
 * @param params
 */
export async function sentSmsApi(params) {
    return await request.post('user/sentSmsApi', params)
}

/**
 * 获取ad事件Id
 */
export async function fetchAdKey(params) {
    return await request.get('loan/supermarket/getAdEventId', {params})
}

/**
 * 获取app数据
 */
export async function fetchProductUserData(params) {
    return await request.get('loan/supermarket/getAppData', {params})
}

/**
 * 前端埋点上传
 * @param params
 */
export async function appBuryingPoint(params) {
    return await request.post('user/appCollectUpload', {
        ...params,
        productName: localStorage.getItem('productName')
    })
}

/**
 * 上传设备信息
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export async function uploadDeviceInfo(params) {
    return await request.post('user/uploadDeviceInfo', params)
}

/**
 * 获取用户最新贷款记录
 */
export async function fetchUserNewLoan(params) {
    return await request.get('queryNewLoanV2', {params})
}
/**
 * 额度计算api 每次跳转页面调用
 */
export async function limitCalculate(params) {
    return await request.get('homepage/week/limit/calculate', {params})
}
/**
 * 获取首页申请历史
 */
export async function fetchApplyHistory(params) {
    return await request.get('user/getShuffling', {params})
}

/**
 * 获取信用记录
 */
export async function fetchCreditInfo(params) {
    return await request.get('user/getQuestionById', {params})
}

/**
 * 添加信用记录
 */
export async function addCreditInfo(params) {
    return await request.post('user/addQuestion', params)
}

/**
 * 获取额度
 */
// export async function fetchLimitInfo(params) {
//     return await request.get('loanProduct/getCredits', {params})
// }
/**
 * 贷款确认
 */
export async function fetchCredits(params) {
    return await request.get('loanProduct/loanTrial', {params})
}

/**
 * 是否提示自动复借
 */
export async function isAutoPromptLoan(params) {
    return await request.get('order/isPromptLoan', {params})
}

/**
 * 订单结清自动复借
 */
export async function isAutoPromptLoanOrder(params) {
    return await request.get('submitPageIsAutomaticLoan', {params})
}

/**
 * 自动复借生成订单
 */
export async function autoLoanCreateOrder(params) {
    return await request.post('order/generateOrder', params)
}

/**
 * 自动复借开关
 */
export async function updateAutoLoan(params) {
    return await request.get('/updateAutomaticLoan', {params})
}

/**
 *
 */
export async function isAutomaticLoan(params) {
    return await request.get('/isAutomaticLoan', {params})
}

/**
 * 是否下载通讯录app
 */
export async function isTipsDownloadAddress(params) {
    return await request.get('/user/isTipsDownloadAddress', {params})
}

// 获取是否好评弹窗
export async function getIsFavorable(params) {
    return await request.get('/user/getComment', {params})
}

/**
 * 获取advanceToken
 */
export async function getAdvanceToken(params) {
    return await request.post('operator/advance/token', params)
}

/**
 * 获取身份验证开关
 * livingSwitch活体开关0关闭,1开启
 ocrSwitch ocr开关 0关闭1开启
 faceSwitch 人脸开关,0关闭,1开启
 */
export async function getConfigSwitch(params) {
    return await request.get('/user/isStartOrcLiving', {params})
}

/**
 图片ocr识别
 */
export async function uploadOcr(params) {
    return await request.post('/user/ocr/recognize', params)
}
